﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblNoiDungDAO
    {
        private DBService _db = null;

        public TblNoiDungDAO(String connectionString)
        {
            _db = new DBService(connectionString);
        }

        public bool InsUpdItem(TblNoidung Noidung, int mode)
        {
            bool flag = false;
            try
            {
                _db.ExeSP_NonQuery("sp_TblNoidung_InsUp",
                    new string[] { "@IDNoiDung", "@ItemTypeNoiDung", "@Title", "@NoiDungDescription", "@Datetime", "@Mode" },
                    new object[] { Noidung.IDNoiDung, Noidung.ItemTypeNoiDung, Noidung.Title, Noidung.NoiDungDescription, Noidung.Datetime, mode},
                    CommandType.StoredProcedure);
                flag = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return flag;
        }

        public DataTable GetNoiDung(int typeNoidung)
        {
            DataTable dt = null;
            dt = _db.ExeSP_DataTable("select * from TblNoidung",
                new string[] {"@typeNoidung" },
                new object[] { typeNoidung }, CommandType.Text);
            return dt;

        }
    }
}
